home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROCS.ZIP / READTBL.ICN < prev    next >
Text File  |  1992-09-28  |  2KB  |  84 lines

  1. ############################################################################
  2. #
  3. #    File:     readtbl.icn
  4. #
  5. #    Subject:  Procedures to read user-created stripsgml table
  6. #
  7. #    Author:   Richard L. Goerwitz
  8. #
  9. #    Date:     June 1, 1991
  10. #
  11. ###########################################################################
  12. #
  13. #    Version:  1.1
  14. #
  15. ###########################################################################
  16. #  
  17. #  This file is part of the strpsgml package.  It does the job of read-
  18. #  ing option user-created mapping information from a file.  The purpose
  19. #  of this file is to specify how each code in a given input text should
  20. #  be translated.  Each line has the form:
  21. #
  22. #      SGML-designator    start_code    end_code
  23. #
  24. #  where the SGML designator is something like "quote" (without the quota-
  25. #  tion marks), and the start and end codes are the way in which you want
  26. #  the beginning and end of a <quote>...<\quote> sequence to be transla-
  27. #  ted.  Presumably, in this instance, your codes would indicate some set
  28. #  level of indentation, and perhaps a font change.  If you don't have an
  29. #  end code for a particular SGML designator, just leave it blank.
  30. #
  31. ############################################################################
  32. #
  33. #  Links: strpsgml.icn
  34. #
  35. ############################################################################
  36.  
  37. link strpsgml
  38.  
  39. procedure readtbl(f)
  40.  
  41.     local t, line, k, on_sequence, off_sequence
  42.  
  43.     /f & stop("readtbl:  Arg must be a valid open file.")
  44.  
  45.     t := table()
  46.  
  47.     every line := trim(!f,'\t ') do {
  48.     line ? {
  49.         k := tabslashupto('\t:') &
  50.         tab(many('\t:')) &
  51.         on_sequence := tabslashupto('\t:') | tab(0)
  52.         tab(many('\t:'))
  53.         off_sequence := tab(0)
  54.     } | stop("readtbl:  Bad map file format.")
  55.     insert(t, k, outstr(on_sequence, off_sequence))
  56.     }
  57.  
  58.     return t
  59.  
  60. end
  61.  
  62.  
  63.  
  64. procedure tabslashupto(c,s)
  65.  
  66.     POS := &pos
  67.  
  68.     while tab(upto('\\' ++ c)) do {
  69.     if ="\\" then {
  70.         move(1)
  71.         next
  72.     }
  73.     else {
  74.         if any(c) then {
  75.         suspend &subject[POS:.&pos]
  76.         }
  77.     }
  78.     }
  79.  
  80.     &pos := POS
  81.     fail
  82.  
  83. end
  84.